/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.klikmee.sms.core.model;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * 
 * @author makcro
 */
@Entity
@Table(name = "distributionlist")
@NamedQueries({
		@NamedQuery(name = "DistributionList.findAll", query = "SELECT d FROM DistributionList d"),
		@NamedQuery(name = "DistributionList.findById", query = "SELECT d FROM DistributionList d WHERE d.id = :id"),
		@NamedQuery(name = "DistributionList.findByListName", query = "SELECT d FROM DistributionList d WHERE d.listName = :listName"),
		@NamedQuery(name = "DistributionList.findByDescription", query = "SELECT d FROM DistributionList d WHERE d.description = :description"),
		@NamedQuery(name = "DistributionList.findByNote", query = "SELECT d FROM DistributionList d WHERE d.note = :note"),
		@NamedQuery(name = "DistributionList.findByMTSServiceId", query = "SELECT d FROM DistributionList d WHERE d.service.mtsServiceId = :mtsServiceId"),
		@NamedQuery(name = "DistributionList.findByMTSListIdAndMTSServiceId", query = "SELECT d FROM DistributionList d WHERE d.service.mtsServiceId = :mtsServiceId AND d.listMTSId = :mtsListId")})
		
public class DistributionList implements Serializable {
	private static final long			serialVersionUID	= 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional = false)
	@Column(name = "Id", nullable = false)
	private Long						id;
	@Column(name = "ListName", length = 256)
	private String						listName;
	@Column(name = "ListMTSId", length = 256)
	private String						listMTSId;

	@Column(name = "SubscribeRegEx", length = 256)
	private String						subscribeRegEx;

	@Column(name = "Description", length = 1024)
	private String						description;
	@Column(name = "Note", length = 1024)
	private String						note;
	@JoinColumn(name = "ServiceId", referencedColumnName = "Id")
	@ManyToOne
	private Service						service;
	@OneToMany(mappedBy = "distributionList")
	private Set<DistributionListItem>	distributionListItemSet;

	public DistributionList() {
	}

	public DistributionList( Long id ) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public void setId( Long id ) {
		this.id = id;
	}

	public String getListName() {
		return listName;
	}

	public void setListName( String listName ) {
		this.listName = listName;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription( String description ) {
		this.description = description;
	}

	public String getNote() {
		return note;
	}

	public void setNote( String note ) {
		this.note = note;
	}

	public String getListMTSId() {
		return listMTSId;
	}

	public void setListMTSId( String listMTSId ) {
		this.listMTSId = listMTSId;
	}

	public Service getService() {
		return service;
	}

	public String getSubscribeRegEx() {
		return subscribeRegEx;
	}

	public void setSubscribeRegEx( String subscribeRegEx ) {
		this.subscribeRegEx = subscribeRegEx;
	}

	public void setService( Service serviceId ) {
		this.service = serviceId;
	}

	public Set<DistributionListItem> getDistributionListItemSet() {
		return distributionListItemSet;
	}

	public void setDistributionListItemSet( Set<DistributionListItem> distributionListItemSet ) {
		this.distributionListItemSet = distributionListItemSet;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals( Object object ) {
		if (!(object instanceof DistributionList)) {
			return false;
		}
		DistributionList other = (DistributionList) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals( other.id ))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "com.klikmee.sms.core.model.DistributionList[ id=" + id + " ]";
	}

}
